package com.zyh.queue;

import java.util.LinkedList;
import java.util.Queue;

/**
 * @Author zyh
 * @Date 2024/7/31 15:36
 * @Description 队列
 */

public class QueueDemo1 {
    public static void main(String[] args) {
        Queue<Integer> queue=new LinkedList<>();
        queue.add(1);
        queue.add(2);
        queue.add(3);
        queue.offer(4);
        System.out.println("queue = " + queue);//queue = [1, 2, 3, 4]
        Integer element = queue.element();
        System.out.println("element = " + element);//element = 1
        System.out.println("queue = " + queue);//queue = [1, 2, 3, 4]
        Integer peek = queue.peek();
        System.out.println("peek = " + peek);//peek = 1
        System.out.println("queue = " + queue);//queue = [1, 2, 3, 4]
        Integer remove = queue.remove();
        System.out.println("remove = " + remove);//remove = 1
        System.out.println("queue = " + queue);//queue = [2, 3, 4]
        Integer poll = queue.poll();
        System.out.println("poll = " + poll);//poll = 2
        System.out.println("queue = " + queue);//queue = [3, 4]
        boolean empty = queue.isEmpty();
        System.out.println("empty = " + empty);//empty = false
        while (!queue.isEmpty()){
            queue.poll();
        }
        System.out.println("queue = " + queue);//queue = []
    }
}
